//
//  WEXBaseVisitorTableVC.m
//  microBlog_oc
//
//  Created by apple on 16/4/17.
//  Copyright © 2016年 Hill. All rights reserved.
//

#import "WEXBaseVisitorTableVC.h"
#import "WEXVisitorView.h"

#import "WEXOAuthViewController.h"
#import "WEXUserAccountViewModel.h"

@interface WEXBaseVisitorTableVC ()<WEXVisitorViewDelegate>



@end

@implementation WEXBaseVisitorTableVC

# pragma mark -
# pragma mark 懒加载
//懒加载WEXVisitorView
- (WEXVisitorView *)visitor {
    
    if ( nil == _visitor) {
        
        _visitor = [[WEXVisitorView alloc] init];
        
        _visitor.delegate = self;
    }
    
    return _visitor;
}


-(void)loadView {
    
    
    self.userLogon = [WEXUserAccountViewModel sharedViewMoel].isLogin;
    
    self.userLogon ? [super loadView]: [self setupView];
    
    
}


- (void)setupView{
    
    self.view = self.visitor;
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:(UIBarButtonItemStylePlain) target:self action:@selector(VisitorView:withRegisteButton:)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登录" style:(UIBarButtonItemStylePlain) target:self action:@selector(VisitorView:withLoginButton:)];
}




# pragma mark -
# pragma mark 代理方法

//实现WEXVisitorView的注册方法
- (void)VisitorView:(WEXVisitorView *)visitorView withRegisteButton:(UIButton *)button{
    
//    NSLog(@"哎呀， 注册啦");
    
}

//实现WEXVisitorView的登录
- (void)VisitorView:(WEXVisitorView *)visitorView withLoginButton:(UIButton *)button {
 
//    NSLog(@"哎呀， 登录啦");
    WEXOAuthViewController *oauthVc = [[WEXOAuthViewController alloc] init];
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:oauthVc];
    
    [self.navigationController presentViewController:nav animated:YES completion:nil];
    
}



@end
